package cn.lxh.controller.app;

import cn.lxh.pojo.app.dto.AuthMaterialDto;
import cn.lxh.result.JSONResult;
import cn.lxh.service.IDriverAuthMaterialService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.io.IOException;

/**
 * @author lxh Create Time: 2024/1/1 15:48
 * AppRealNameAuthController控制层
 */
@Tag(name = "App司机对象",description = "App司机对象")
@RestController
@RequestMapping("/app/realNameAuth")
public class AppRealNameAuthController {
    @Autowired
    public IDriverAuthMaterialService driverAuthMaterialService;

    @Operation( summary= "司机实名认证材料提交",description = "司机实名认证材料提交")
    @Parameter(name = "authMaterialDto",description = "认证材料参数authMaterialDto",required = true)
    @PostMapping("/applyAuthMaterial")
    public JSONResult applyAuthMaterial(@RequestBody @Valid AuthMaterialDto authMaterialDto){
        try {
            return JSONResult.success(driverAuthMaterialService.applyAuthMaterial(authMaterialDto));
        } catch (IOException e) {
            e.printStackTrace();
            return JSONResult.error();
        }
    }

    @Operation( summary= "司机实名认证材料查询",description = "司机实名认证材料查询")
    @Parameter(name = "authMaterialDto",description = "认证材料参数authMaterialDto",required = true)
    @GetMapping("/selectMaterial")
    public JSONResult selectMaterial(){
        return JSONResult.success(driverAuthMaterialService.selectMaterial());
    }

}
